package com.yxinsur.imc.web.controller.business;

import java.util.List;

import com.yxinsur.imc.business.domain.ImcFundOrderVariable;
import com.yxinsur.imc.business.service.IImcFundOrderVariableService;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.yxinsur.imc.common.annotation.Log;
import com.yxinsur.imc.common.core.controller.BaseController;
import com.yxinsur.imc.common.core.domain.AjaxResult;
import com.yxinsur.imc.common.enums.BusinessType;
import com.yxinsur.imc.common.utils.poi.ExcelUtil;
import com.yxinsur.imc.common.core.page.TableDataInfo;

/**
 * 保单口径变量(对应下拉列应显示的内容)Controller
 *
 * @author imc
 * @date 2021-10-29
 */
@RestController
@RequestMapping("/business/fund/order/variable")
public class ImcFundOrderVariableController extends BaseController {
    @Autowired
    private IImcFundOrderVariableService imcFundOrderVariableService;

    /**
     * 查询保单口径变量(对应下拉列应显示的内容)列表
     */
    @ApiOperation("查询保单口径变量")
    @GetMapping("/list")
    public AjaxResult list() {
        return AjaxResult.success(this.imcFundOrderVariableService.listVariable());
    }

    /**
     * 导出保单口径变量(对应下拉列应显示的内容)列表
     */
    @PreAuthorize("@ss.hasPermi('system:variable:export')")
    @Log(title = "保单口径变量(对应下拉列应显示的内容)", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(ImcFundOrderVariable imcFundOrderVariable) {
        List<ImcFundOrderVariable> list = imcFundOrderVariableService.selectImcFundOrderVariableList(imcFundOrderVariable);
        ExcelUtil<ImcFundOrderVariable> util = new ExcelUtil<ImcFundOrderVariable>(ImcFundOrderVariable.class);
        return util.exportExcel(list, "variable");
    }

    /**
     * 获取保单口径变量(对应下拉列应显示的内容)详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:variable:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(imcFundOrderVariableService.selectImcFundOrderVariableById(id));
    }

    /**
     * 新增保单口径变量(对应下拉列应显示的内容)
     */
    @PreAuthorize("@ss.hasPermi('system:variable:add')")
    @Log(title = "保单口径变量(对应下拉列应显示的内容)", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ImcFundOrderVariable imcFundOrderVariable) {
        return toAjax(imcFundOrderVariableService.insertImcFundOrderVariable(imcFundOrderVariable));
    }

    /**
     * 修改保单口径变量(对应下拉列应显示的内容)
     */
    @PreAuthorize("@ss.hasPermi('system:variable:edit')")
    @Log(title = "保单口径变量(对应下拉列应显示的内容)", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ImcFundOrderVariable imcFundOrderVariable) {
        return toAjax(imcFundOrderVariableService.updateImcFundOrderVariable(imcFundOrderVariable));
    }

    /**
     * 删除保单口径变量(对应下拉列应显示的内容)
     */
    @PreAuthorize("@ss.hasPermi('system:variable:remove')")
    @Log(title = "保单口径变量(对应下拉列应显示的内容)", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids) {
        return toAjax(imcFundOrderVariableService.deleteImcFundOrderVariableByIds(ids));
    }
}
